﻿// <copyright file="MainViewModel.cs" company="Ucaya">
// </copyright>
// <author>Ucaya</author>

namespace Channel9Kinect
{
    #region

    using System;
    using System.ComponentModel;
    using System.ComponentModel.Composition;
    using System.Linq.Expressions;
    using System.Windows.Input;

    using Channel9Kinect.Input;
    using Channel9Kinect.Services;

    #endregion

    internal class MainViewModel : INotifyPropertyChanged
    {
        #region Constructors and Destructors

        /// <summary>
        ///   Initializes a new instance of the <see cref = "MainViewModel" /> class.
        /// </summary>
        public MainViewModel()
        {
            ServiceLocator.Instance.SatisfyImportsOnce(this);

            this.NavigateToC4F = new Command(() =>
                {
                    this.NavigationServiceWrapper.NavigationService.NavigateTo(new Uri("Wall.xaml", UriKind.Relative), Tuple.Create(FeedService.C4f, new Uri("/Channel9Kinect;component/Assets/ch9.jpg", UriKind.Relative)));
                });
            this.NavigateToPing = new Command(() =>
                {
                    this.NavigationServiceWrapper.NavigationService.NavigateTo(new Uri("Wall.xaml", UriKind.Relative), Tuple.Create(FeedService.Ping, new Uri("/Channel9Kinect;component/Assets/ping.jpg", UriKind.Relative)));
                });
            this.NavigateToWebCamp = new Command(() =>
                {
                    this.NavigationServiceWrapper.NavigationService.NavigateTo(new Uri("Wall.xaml", UriKind.Relative), Tuple.Create(FeedService.Webcamp, new Uri("/Channel9Kinect;component/Assets/webtv.jpg", UriKind.Relative)));
                });
            this.NavigateToWeek = new Command(() =>
                {
                    this.NavigationServiceWrapper.NavigationService.NavigateTo(new Uri("Wall.xaml", UriKind.Relative), Tuple.Create(FeedService.Ch9, new Uri("/Channel9Kinect;component/Assets/week.jpg", UriKind.Relative)));
                });
        }

        #endregion

        #region Public Events

        /// <summary>
        ///   The property changed.
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;

        #endregion

        #region Public Properties

        public ICommand NavigateToC4F { get; private set; }

        public ICommand NavigateToPing { get; private set; }

        public ICommand NavigateToWebCamp { get; private set; }

        public ICommand NavigateToWeek { get; private set; }

        [Import]
        public NavigationServiceWrapper NavigationServiceWrapper { get; set; }

        #endregion

        #region Methods

        /// <summary>
        ///   The raise property changed.
        /// </summary>
        /// <param name = "expression">
        ///   The expression.
        /// </param>
        /// <typeparam name = "TProperty">
        /// </typeparam>
        protected void RaisePropertyChanged<TProperty>(Expression<Func<MainViewModel, TProperty>> expression)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(this.GetPropertyName(expression)));
            }
        }

        #endregion
    }
}